package com.training.bt.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.training.bt.entity.Comment;
import com.training.bt.mapper.CommentMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService extends ServiceImpl<CommentMapper, Comment> implements ICommentService {

    @Override
    public Comment addComment(Comment comment) {
        save(comment);
        return comment;
    }

    @Override
    public void deleteComment( Long commentId) {
        removeById(commentId);
    }

    @Override
    public List<Comment> getCommentsByPostId( Long postId) {
        return baseMapper.selectByPostId(postId);
    }

    @Override
    public List<Comment> getCommentsByUserId( Long userId) {
        return baseMapper.selectByUserId(userId);
    }
}